import { request } from '@/service';
import type { ICreateUser, IQueryInfo } from '@/types/system';

export function POST_USER_LIST_DATA(pageInfo: IQueryInfo) {
  return request.post({
    url: '/users/list',
    data: pageInfo
  });
}

export function DELETE_USER_BY_ID(id: number) {
  return request.delete(`/users/${id}`);
}

export function CREATE_USER(userInfo: ICreateUser) {
  return request.post({
    url: '/users',
    data: userInfo
  });
}

export function EDIT_USER(id: number, userInfo: any) {
  return request.patch({
    url: `/users/${id}`,
    data: userInfo
  });
}

/** 针对页面的网络请求 */
export function POST_PAGE_LIST_DATA(pageName: string, queryInfo: any) {
  return request.post({
    url: `/${pageName}/list`,
    data: queryInfo
  });
}

export function DELETE_PAGE_RECORD_BY_ID(pageName: string, id: number) {
  return request.delete(`/${pageName}/${id}`);
}

export function CREATE_PAGE_RECORD(pageName: string, recordInfo: any) {
  return request.post({
    url: `/${pageName}`,
    data: recordInfo
  });
}

export function EDIT_PAGE_RECORD(pageName: string, id: number, recordInfo: any) {
  return request.patch({
    url: `/${pageName}/${id}`,
    data: recordInfo
  });
}
